<template>
  <div>
    <ZgDialog
      v-model="visible"
      title="新增模板"
      top="10%"
      width="30%"
      @ok="save">
      <a-form :labelCol="{ span: 6 }" :wrapperCol="{ span: 18 }">
        <a-form-item label="模板名称" required>
          <ZgInput v-model="obj.name"></ZgInput>
        </a-form-item>
        <a-form-item label="是否默认模板" required>
          <a-radio-group v-model="obj.isDefault">
            <a-radio :value="true">是</a-radio>
            <a-radio :value="false">否</a-radio>
          </a-radio-group>
        </a-form-item>
        <a-form-item label="签章x轴">
          <ZgNumber style="width:45%" v-model="obj.signX"></ZgNumber>
        </a-form-item>
        <a-form-item label="签章y轴">
          <ZgNumber style="width:45%" v-model="obj.signY"></ZgNumber>
        </a-form-item>
      </a-form>
    </ZgDialog>
  </div>
</template>
<script>
export default {
  props: {
    formId: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      visible: false,
      typeList: [
        { value: '1', label: '单数' },
        { value: '2', label: '复数' },
        { value: '3', label: '拆分' }
      ],
      obj: {
        name: '',
        isDefault: false,
        signX: null,
        signY: null
      }
    }
  },
  methods: {
    open () {
      this.obj.name = ''
      this.visible = true
    },
    save () {
      if (this.obj.name.length === 0) {
        this.$warning({ title: '请输入模板名称' })
        return
      }
      this.obj.formId = this.formId
      this.$http.post('/zg-autoform/tmpl/add', this.obj, data => {
        this.$emit('ok', 'add')
        this.visible = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
